// src/store/index.js
import { legacy_createStore as createStore, applyMiddleware } from "redux";
import thunkMiddleware from "redux-thunk";
import { createLogger } from "redux-logger";
import rootReducer from "../reducers";

// 仅在开发环境启用日志中间件
const middlewares = [thunkMiddleware];
if (process.env.NODE_ENV === "development") {
  middlewares.push(createLogger());
}

export default function configStore() {
  const store = createStore(rootReducer, applyMiddleware(...middlewares));
  return store;
}